<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">
        <style>
            .ui-state-highlight.ui-selected {
                color: blueviolet;
            }
            .ui-commandButton-wizard-selected{
                background-color: #D20005;
                font-weight: bold;
                color: #000000;
            }
            .ui-commandButton-wizard-unselected{
                background-color: #D20005;
                font-weight: bold;
                color: #AFAFAF;
            }
        </style>
        <h:form id="salesInquiryForm" style="font-size: 85%">
            <h2>View Sales Inquiry</h2>
            <br/>

            <p:panel>
                <p:messages />
                <br/>
                <h:panelGrid columns="3" cellpadding="10">
                    <h:outputLabel for="siNumber" style="font-weight: bold" value="Sales Inquiry #: "/>
                    <h:outputLabel id="siNumber" style="font-weight: bold" value="#{slManagerBean.salesInquiry.siNumber}"/>
                    <h:outputText value=""/>

                    <h:outputLabel style="font-weight: bold" value="Client ID: "/>
                    <h:outputText id="clientId" value="#{slManagerBean.salesInquiry.salesLead.clientId}"/>
                    <h:outputText value=""/>

                    <h:outputLabel style="font-weight: bold" value="Company Name: "/>
                    <h:outputText id="companyName" value="#{slManagerBean.salesInquiry.salesLead.companyName}" />
                    <h:outputText value=""/>

                    <h:outputLabel for="rfiNumber" style="font-weight: bold" value="Request For Inquiry #: "/>
                    <h:outputText id="rfiNumber" value="#{slManagerBean.salesInquiry.rfiNumber}"/>
                    <h:outputText value=""/>

                    <h:outputLabel for="date" style="font-weight: bold" value="Date: "/>
                    <h:outputText id="date" value="#{slManagerBean.salesInquiry.inquiryDate}">
                        <f:convertDateTime pattern="MMMM dd, yyyy"/>
                    </h:outputText> 
                    <h:outputText value=""/>

                    <h:outputLabel style="font-weight: bold" value="Currency: "/>
                    <h:selectOneRadio id="currency" required="true" requiredMessage="Please select one currency" value="#{slManagerBean.salesInquiry.currency}" disabled="true">
                        <f:selectItem itemLabel="SGD" itemValue="true"/>
                        <f:selectItem itemLabel="USD" itemValue="false"/>
                    </h:selectOneRadio>
                    <h:outputText value=""/>

                </h:panelGrid>

                <br/>
                <br/>
                <br/>

                <h:outputText value="Order Items" style="font-weight: bold; font-size: 110%"/>
                <p:separator title="Order Items"/> 
                <br/>
                <p:dataTable var="oneIL" value="#{slManagerBean.salesInquiry.orderItems}">
                    <p:column headerText="Product Type" rendered="#{oneIL.qtyOrderedCase != 0}">
                        <h:outputText value="#{oneIL.product.productType}" />
                    </p:column>
                    <p:column headerText="Quantity Ordered Case" rendered="#{oneIL.qtyOrderedCase != 0}">
                        <h:outputText value="#{oneIL.qtyOrderedCase}" />
                    </p:column>
                    <p:column headerText="Case Unit Price (SGD)" rendered="#{(oneIL.qtyOrderedCase != 0) &amp;&amp; (slManagerBean.salesInquiry.currency)}">
                        <h:outputText value="#{oneIL.unitPriceSGD}" >
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Case Unit Price (USD)" rendered="#{(oneIL.qtyOrderedCase != 0) &amp;&amp; (!slManagerBean.salesInquiry.currency)}">
                        <h:outputText value="#{oneIL.unitPriceUSD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Order Discount" rendered="#{oneIL.qtyOrderedCase != 0}">
                        <h:outputText value="#{oneIL.orderDiscount}" />
                    </p:column>
                    <p:column headerText="Member Discount" rendered="#{oneIL.qtyOrderedCase != 0}">
                        <h:outputText value="#{oneIL.memberDiscount}" />
                    </p:column>
                    <p:column headerText="Sub-total" rendered="#{oneIL.qtyOrderedCase != 0}">
                        <h:outputText value="#{oneIL.subTotal}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                </p:dataTable>
                <br/>
                <br/>
                <br/>

                <h:outputText value="Comments" style="font-weight: bold; font-size: 110%"/>
                <p:separator title="Comments"/>
                <br/>
                <h:panelGrid columns="6" cellpadding="10">
                    <h:outputText value="#{slManagerBean.salesInquiry.comments}"/>
                </h:panelGrid>
                <br/>
                <br/>
                <br/>
                <p:separator style="height:1px; border-color: #000000; color: #000000; background-color: #000000; outline-color: #000000"/> 
                <br/>
                <div align="right">
                    <h3>
                        <h:panelGrid columns ="2" cellpadding="2" style="text-align: right">
                            <h:outputLabel style="font-weight: bold" value="Sub-total: "/>
                            <h:outputText value="#{slManagerBean.salesInquiry.subtotal}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                            <h:outputLabel style="font-weight: bold" value="Order Discount: "/>
                            <h:outputText value="#{slManagerBean.salesInquiry.orderDiscount}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                            <h:outputLabel style="font-weight: bold" value="Member Discount: "/>
                            <h:outputText value="#{slManagerBean.salesInquiry.memberDiscount}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                        </h:panelGrid>
                    </h3>
                    <h2>
                        <h:panelGrid columns ="2" cellpadding="10">
                            <h:outputLabel for="total" style="font-weight: bold" value="Total: "/>
                            <h:outputText id="total" value="#{slManagerBean.salesInquiry.total}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                        </h:panelGrid>
                    </h2>
                </div>
                <br/>
            </p:panel>

            <br/>
            <br/>
            <br/>
            <div align="right">
                <p:commandButton id="closeSI" value="Close Sales Inquiry" action="#{slManagerBean.closeSalesInquiry}"  image="ui-icon ui-icon-close" title="cancellation"/>
                <p:commandButton id="editSI" value="Update" ajax="false" action="#{slManagerBean.updateSalesInquiry}" image="ui-icon ui-icon-pencil" />
            </div>
            <br/>
            <br/>
            <br/>

        </h:form>
        <p:confirmDialog message="Are you sure about cancelling the sales inquiry?" width="200"  
                         showEffect="explode" hideEffect="explode"  
                         header="Initiating cancellation" severity="alert" widgetVar="confirmation">
            <h:form id="confirmDialog">
                <p:commandButton value="Yes" update="growl" action="#{slManagerBean.cancelSalesInquiry}" oncomplete="confirmation.hide()"/>  
                <p:commandButton value="No" onclick="confirmation.hide()" type="button" />
            </h:form>
        </p:confirmDialog>
    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
